package core.types;

public enum PrimitiveType {

	BOOLEAN(null), CHAR(null), INTEGER(PrimitiveType.CHAR), LONGINT(PrimitiveType.INTEGER), REAL(
			null), LONGREAL(PrimitiveType.REAL), STRING(null);

	PrimitiveType compatibleType;

	PrimitiveType(PrimitiveType compatibleType) {
		this.compatibleType = compatibleType;
	}

	public static PrimitiveType getWiderType(PrimitiveType firstType,
			PrimitiveType secondType) {
		return firstType.equals(secondType) ? firstType
				: (firstType.compatibleType != null
						&& firstType.compatibleType.equals(secondType) ? firstType
						: (secondType.compatibleType != null
								&& secondType.compatibleType.equals(firstType) ? secondType
								: null));
	}
	
}
